# 博客链接 https://blog.csdn.net/bananapai/article/details/145736300
from keras import layers, models


def create_alexnet(input_shape=(224, 224, 3), num_classes=1000):
    m = models.Sequential()
    m.add(layers.Conv2D(96, kernel_size=(11, 11), strides=(4, 4), padding='same', activation='relu', input_shape=input_shape))
    m.add(layers.MaxPooling2D((3, 3), strides=2))

    m.add(layers.Conv2D(256, (5, 5), padding='same', activation='relu'))
    m.add(layers.MaxPooling2D((3, 3), strides=2))

    m.add(layers.Conv2D(384, kernel_size=(3, 3), padding='same', activation='relu'))
    m.add(layers.Conv2D(384, kernel_size=(3, 3), padding='same', activation='relu'))
    m.add(layers.Conv2D(256, kernel_size=(3, 3), padding='same', activation='relu'))
    m.add(layers.MaxPooling2D((3, 3), strides=(2, 2)))

    m.add(layers.Flatten())
    m.add(layers.Dense(4096, activation='relu'))
    m.add(layers.Dropout(0.5))
    m.add(layers.Dense(4096, activation='relu'))
    m.add(layers.Dropout(0.5))
    m.add(layers.Dense(num_classes, activation='softmax'))

    return m


# m = create_alexnet()
#
# m.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
# m.summary()

# print(444)
